{% extends 'IcsocUIBundle::page.html.twig' %}
{% from 'IcsocUIBundle:Macro:grid.html.twig' import gridWidth,gridNav,gridConfig,sendKeyWord,gridKeyword %}
{% block stylesheet %}
    {{ parent() }}
    {% stylesheets
    '@jqgird_css'
    '@gritter_css'
    filter='cssrewrite' filter='uglifycss'
    %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

{% block content %}
    {{ gridKeyword('The schedule name'|trans) }}
    <table id="grid-table"></table>
    <div id="grid-pager"></div>
{% endblock %}
{% block footer %}
    {% javascripts
    '@jqgird_js'
    '@gritter_js'
    '@common_js'
    filter='uglifyjs'
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}
    <script type="text/javascript">
        jQuery(function($) {
            {{ gridWidth() }}
            jQuery(grid_selector).jqGrid({
                url: "{{ path('icsoc_rules_data') }}",  //数据；
                colNames:['{{ 'actions'|trans }}','id', '{{ 'Agenda rule name'|trans }} ','{{ 'The genus number'|trans }}','{{ 'Priority'|trans }}',
                    '{{ 'Start date'|trans }}','{{ 'End date'|trans }}', '{{ 'Start time'|trans }}','{{ 'End time'|trans }}','{{ 'Week'|trans }}','{{ 'The IVR process'|trans }}','{{ 'Create time'|trans }}',''],  //列显示名称，是一个数组对象
                colModel:[
                    {name:'myac',index:'', width:80,fixed:true,sortable:false, resize:false,
                        formatter:'actions',
                        formatoptions:{
                            keys:true,
                            editbutton:true,
                            editformbutton: true,
                            delOptions:{recreateForm: true,beforeShowForm:beforeDeleteCallback, afterSubmit:afterDeleteCallback,left:540,top:206},
                            editOptions:{width: "0",height: "0", jqModal:false, beforeShowForm:beforeEditCallback }
                        }
                    },
                    {name:'ruleId',index:'ruleId',  hidden:true,editable: true,key:true},
                    {name:'ruleName',index:'ruleName', editable:true, sortable:true},
                    {name:'phoneId',editable:true, sortable:false,formatter:function(cell,obj,row){
                        return cell != 0 ? row.phone+'['+row.phone400+']' : "{{ 'All'|trans }}";
                    }},
                    {name:'priority',index:'priority', editable:true, sortable:false},
                    {name:'startDate',index:'startDate', editable:true, sortable:true,formatter:render},
                    {name:'endDate',index:'endDate',editable:true, sortable:false,formatter:render},
                    {name:'startTime',index:'startTime', editable:true, sortable:false,formatter:render},
                    {name:'endTime',index:'endTime', editable:true, sortable:false,formatter:render},
                    {name:'weeks',index:'weeks',editable:true, sortable:false},
                    {name:'ivrName',index:'ivrName', editable:true, sortable:false},
                    {name:'addTime',index:'addTime',editable:true, sortable:false,width:150,fixed:true },
                    {name:'id',index:'id', hidden:true,editable:true,formatter:function(cellvalue, options, rowObject){
                        return  rowObject.ruleId;
                    }}
                ],
                {{ gridConfig() }}
                editurl: "{{ path('icsoc_rules_del') }}",//nothing is saved 定义对form编辑时的url
                caption: "{{ 'Schedule list'|trans }}", //表格名称
                sortname: 'ruleId'
            });
            {{ gridNav(false,false,true,false,true,true,path('icsoc_rules_add'),path('icsoc_rules_edit')) }}
        });
        {{ sendKeyWord() }}

        function render(cell, options, row)
        {
            return cell == '*' ? '任意' : cell;
        }
    </script>
{% endblock %}